﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" src="../bob.js"></script>
</head>
<body>

    <!-- without namespaces -->
    <script type="text/javascript">
        function saveLog(log) {
            console.log(log); 
        }
    </script>
    <script type="text/javascript">
        function saveLog(log) {
            alert(log); 
        }
    </script>
    <script type="text/javascript">
        saveLog('This is a log message.');
    </script>

    <!-- with namespaces -->
    <script type="text/javascript">
        var consoleLogger = {
            saveLog: function (log) {
                console.log(log);
            }
        };
    </script>
    <script type="text/javascript">
        var alertLogger = {
            saveLog: function (log) { 
                alert(log);
            }
        };
    </script>
    <script type="text/javascript">
        consoleLogger.saveLog('This is a log message to Console.');
        alertLogger.saveLog('This is a log message to Alert.');
    </script>

    <!-- with bob.js -->
    <script type="text/javascript">
        delete window['consoleLogger'];
        delete window['alertLogger'];
    </script>

    <script type="text/javascript">
        bob.ns.setNs('consoleLogger', {
            saveLog: function (log) {
                console.log(log);
            }
        });
    </script>
    <script type="text/javascript">
        bob.ns.setNs('alertLogger', {
            saveLog: function (log) {
                alert(log);
            }
        });
    </script>
    <script type="text/javascript">
        consoleLogger.saveLog('This is a bob.js log message to Console.');
        alertLogger.saveLog('This is a bob.js log message to Alert.');
    </script>

    <!-- deep-level -->
    <script type="text/javascript">
        delete window['consoleLogger'];
        delete window['alertLogger'];
    </script>

    <script type="text/javascript">
        bob.ns.setNs('loggers.consoleLogger', {
            saveLog: function (log) {
                console.log(log);
            },

            anotherFunction: function () {
                alert('this is another function');
            }
        });
    </script>
    <script type="text/javascript">
        bob.ns.setNs('loggers.alertLogger', {
            saveLog: function (log) {
                alert(log);
            }
        });
    </script>
    <script type="text/javascript">
        loggers.consoleLogger.saveLog('bob.js nested Console log.');
        loggers.alertLogger.saveLog('bob.js nested Alert log.');
        loggers.consoleLogger.anotherFunction();
    </script>

    <!-- include -->
    <script type="text/javascript">
        delete window['consoleLogger'];
        delete window['alertLogger'];
    </script>

    <script src="loggers.consoleLogger.js" type="text/javascript"></script> 
    <script src="loggers.alertLogger.js" type="text/javascript"></script> 
    <script type="text/javascript">
        loggers.consoleLogger.saveLog('bob.js nested Console log from FILE.');
        loggers.alertLogger.saveLog('bob.js nested Alert log from FILE.'); 
    </script> 


</body>
</html>
